<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\logic;



/**
 * 活动海报逻辑
 */
class Poster extends AdminBase
{



    /**
     * 获取活动海报列表
     */
    public function getPosterList($where = [], $field = 'a.*', $order = '')
    {

        $this->modelPosterPicture->alias('a');

        $where['a.' . DATA_STATUS_NAME] = ['neq', DATA_DELETE];
        $count=$this->modelPosterPicture->alias('a')->where($where)->count();

        $list=$this->modelPosterPicture->alias('a')->field($field)->where($where)->paginate(50);

        return ['list'=>$list,'count'=>$count];
    }



    /**
     * 获取活动海报列表搜索条件
     */
    public function getWhere($data = [])
    {

        $where = [];

       if(!empty($data['id'])){
           $where['id']=$data['id'];
       }

        return $where;
    }




    /**
     * 活动海报信息编辑
     */
    public function PosterEdit($data = [])
    {


        $url = url('PosterList');


        if(empty($data['cover_id'])){
            return [RESULT_ERROR, '图片必须上传'];
        }

        $result = $this->modelPosterPicture->setInfo($data);

        $handle_text = empty($data['id']) ? '新增' : '编辑';

        $result && action_log($handle_text, '活动海报' );

        return $result ? [RESULT_SUCCESS, '活动海报操作成功', $url] : [RESULT_ERROR, $this->modelPoster->getError()];
    }

    /**
     * 获取活动海报信息
     */
    public function getPosterInfo($where = [], $field = 'a.*')
    {

        $this->modelPosterPicture->alias('a');


        $where['a.' . DATA_STATUS_NAME] = ['neq', DATA_DELETE];


        return $this->modelPosterPicture->getInfo($where, $field);
    }

 










}
